<?php

/**
 * This is the model class for table "{{content}}".
 *
 * The followings are the available columns in table '{{content}}':
 * @property string $id
 * @property string $show
 * @property string $image
 * @property string $category
 * @property string $title
 * @property string $permalink
 * @property string $description
 * @property string $alt_title
 * @property string $alt_keywords
 * @property string $alt_description
 * @property integer $updated
 * @property integer $created
 * @property integer $viewcount
 */
class Content extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Content the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{content}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('updated, created, viewcount', 'numerical', 'integerOnly'=>true),
			array('show, image, category', 'length', 'max'=>10),
			array('title, permalink, alt_title, alt_keywords', 'length', 'max'=>255),
			array('description, alt_description', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, show, image, category, title, permalink, description, alt_title, alt_keywords, alt_description, updated, created, viewcount', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'show' => 'Show',
			'image' => 'Image',
			'category' => 'Category',
			'title' => 'Title',
			'permalink' => 'Permalink',
			'description' => 'Description',
			'alt_title' => 'Alt Title',
			'alt_keywords' => 'Alt Keywords',
			'alt_description' => 'Alt Description',
			'updated' => 'Updated',
			'created' => 'Created',
			'viewcount' => 'Viewcount',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('show',$this->show,true);
		$criteria->compare('image',$this->image,true);
		$criteria->compare('category',$this->category,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('permalink',$this->permalink,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('alt_title',$this->alt_title,true);
		$criteria->compare('alt_keywords',$this->alt_keywords,true);
		$criteria->compare('alt_description',$this->alt_description,true);
		$criteria->compare('updated',$this->updated);
		$criteria->compare('created',$this->created);
		$criteria->compare('viewcount',$this->viewcount);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}